package com.itheima.consumer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DelayConfig {

    @Bean
    public DirectExchange directDelayExchange(){
        return ExchangeBuilder.directExchange("normal.exchange").build();
    }

    @Bean
    public Queue delayQueue(){
        return QueueBuilder
                .durable("normal.queue")
                .deadLetterExchange("delay.exchange") // 关联死信交换机
                .build();
    }

    @Bean
    public Binding bindingDelay(){
        return BindingBuilder
                .bind(delayQueue())
                .to(directDelayExchange())
                .with("hi");
    }
}
